<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回调</title>
    <script src="js/config/vue/dist/vue.js"></script>
    <script src="js/config/axios/dist/axios.js"></script>
    <script src="js/common/common.js"></script>
</head>
<body>

</body>

<script type="text/javascript">

    new Vue({
        el:".login-banner",
        data(){
            return {
                loginForm: {
                    username: '13666214711',
                    password: '',
                    type: 1,
                }
            }
        },
        methods:{

        },
        created(){
            let url = location.href
            let paramObj = parseUrlParams2Obj(url)
            console.log(paramObj);
            //封装请求参数
            let param = {"code":paramObj.code};
            //发送微信登录验证
            this.$http.post("/login/weChat",param)
                .then(result=>{
                    console.log(result);
                    result = result.data;//AjaxResult
                    if(result.success){
                        //解构表达式解构对象
                        let {token,loginInfo} = result.resultObj;
                        //储存数据 token + loginInfo
                        localStorage.setItem("token",token);
                        localStorage.setItem("loginInfo",JSON.stringify(loginInfo));
                        //跳转到主页
                        location.href="index.html"
                    }else{
                        let binderUrl ="http://bugtracker.itsource.cn/binder.html"+result.resultObj;
                        location.href=binderUrl;
                    }
                })
                .catch(result=>{
                    alert("系统异常!");
                })
        },
    })

</script>
</html>